package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.RepeatSubmit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.AdvInfoliks;
import com.ruoyi.service.IAdvInfoliksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 *
 * @author ruoyi
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/system/infoliks")
public class AdvInfoliksController extends BaseController
{
    @Autowired
    private IAdvInfoliksService advInfoliksService;

    /**
     * 查询列表
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdvInfoliks advInfoliks)
    {
        startPage();
        List<AdvInfoliks> list = advInfoliksService.selectAdvInfoliksList(advInfoliks);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdvInfoliks advInfoliks)
    {
        List<AdvInfoliks> list = advInfoliksService.selectAdvInfoliksList(advInfoliks);
        ExcelUtil<AdvInfoliks> util = new ExcelUtil<AdvInfoliks>(AdvInfoliks.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:query')")
    @GetMapping(value = "/{advInfoliksId}")
    public AjaxResult getInfo(@PathVariable("advInfoliksId") Long advInfoliksId)
    {
        return success(advInfoliksService.selectAdvInfoliksByAdvInfoliksId(advInfoliksId));
    }

    /**
     * 新增
     */
    @RepeatSubmit
    @PreAuthorize("@ss.hasPermi('system:infoliks:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdvInfoliks advInfoliks)
    {
        return toAjax(advInfoliksService.insertAdvInfoliks(advInfoliks));
    }

    /**
     * 修改
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdvInfoliks advInfoliks)
    {
        return toAjax(advInfoliksService.updateAdvInfoliks(advInfoliks));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('system:infoliks:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{advInfoliksIds}")
    public AjaxResult remove(@PathVariable Long[] advInfoliksIds)
    {
        return toAjax(advInfoliksService.deleteAdvInfoliksByAdvInfoliksIds(advInfoliksIds));
    }

    /**
     * 点赞
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping("/dogood")
    public AjaxResult doGood(@RequestBody AdvInfoliks advInfoliks)
    {
        return toAjax(advInfoliksService.doGood(advInfoliks));
    }

    /**
     * 取消点赞
     */

    @PreAuthorize("@ss.hasPermi('system:infoliks:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping("/cancelgood")
    public AjaxResult canceGood(@RequestBody AdvInfoliks advInfoliks)
    {
        return toAjax(advInfoliksService.canceGood(advInfoliks));
    }
}
